<template>
	<view style="padding-bottom: 120rpx;">
		<u-navbar v-if="!$isWeixin()" :title="title" :title-width="450" :titleBold="true" :background="{ backgroundColor: '#ffffff' }" :is-fixed="true"></u-navbar>

		<u-tabs active-color="#FF7A23" :list="tabList" :current="tabIndex" @change="index => (tabIndex = index)"></u-tabs>

		<view class="" v-if="tabIndex === 0">
			<relations :list="state.This_Dealer_RelationList"></relations>
		</view>

		<view class="" v-if="tabIndex === 1">
			<u-cell-item v-if="state.ShowLevel != 1" title="一级经销商名称" :arrow="false" :border-bottom="state.ShowLevel == 3" :value="state.First_Dealer_BaseInfo.Name"></u-cell-item>

			<view class="" v-if="state.ShowLevel != 3">
				<basic-information
					:data="DealerInfo"
					:showOtherInfo="false"
					:level="state.ShowLevel"
					:showReview="false"
					:showParent="false"
					:showDeliveryAddress="false"
					:loadCity="loadCity"
				></basic-information>
			</view>

			<view class="" v-show="state.ShowLevel == 3">
				<u-cell-item title="二级经销商名称" :arrow="false" :border-bottom="false" :value="state.Double_Dealer_BaseInfo.Name"></u-cell-item>
				<store-information :loadCity="loadCity" :data="state.Door_Dealer_BaseInfo"></store-information>
			</view>
		</view>

		<view class="" v-if="tabIndex === 2">
			<design-information :data="DesignInfo" :showReview="true" :selectType="3"></design-information>
		</view>
		
		<view class="" v-if="tabIndex === 3">
			<u-cell-item :arrow="false" style="padding: 10rpx;" v-if="state.AgreementPhotoList.filter(item => item.TypeId == 1).length > 0">
				<image-upload :readonly="true" :value="state.AgreementPhotoList.filter(item => item.TypeId == 1)"></image-upload>
			</u-cell-item>
			<u-cell-item :arrow="false" style="padding: 10rpx;" v-if="state.AgreementPhotoList.filter(item => item.TypeId == 4).length > 0">
				<file-picker :readonly="true" :value="state.AgreementPhotoList.filter(item => item.TypeId == 4)"></file-picker>
			</u-cell-item>
		</view>
		
		<view class="" v-if="tabIndex === 4">
			<agreement-review :data="state.OtherAgreementInfo"></agreement-review>
		</view>
		
		<view class="btn-group-fixed">
			<u-button @tap="backToList">返回列表</u-button>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			title: '其他设计验收审核详情',
			tabList: [{ name: '销售业务关系' }, { name: '基本信息' }, { name: '其他设计信息'}, { name: '其他设计验收上传'}, { name: '审核信息'}],
			tabIndex: 0,

			AgreementAcceptanceId: 1045,
			loadCity: false,

			state: {
				AgreementPhotoList: [],
				DealerAuditInfo: {},
				DesignPhotoList: [],
				Door_Dealer_BaseInfo: {},
				Double_Dealer_BaseInfo: {},
				FileList: [],
				First_Dealer_BaseInfo: {},
				InitialPhotoList: [],
				OtherAgreementInfo: {},
				ShowLevel: null,
				This_Dealer_OtherInfo: {},
				This_Dealer_RelationList: []
			},

			DealerInfo: {
				Dealer_BaseInfo: {},
				Dealer_OtherInfo: {}
			},
			
			DesignInfo: {
				InitialPhotoList: [],
				DesignPhotoList: [],
				FileList: [],
				DealerAuditInfo: {},
			}
		};
	},

	onLoad(options) {
		if (options.AgreementAcceptanceId) {
			this.AgreementAcceptanceId = options.AgreementAcceptanceId;
		}

		this.init();
		if(this.$isWeixin()) {
			this.$setTitle(this.title);
		}
	},

	methods: {
		
		backToList() {
			this.$u.route({
				url: '/pages/review/agreement/index',
				params: {
					SelectType: 3
				}
			})
		},
		init() {
			this.$u.api
				.getOtherDesignReviewDetail({
					AgreementAcceptanceId: this.AgreementAcceptanceId
				})
				.then(res => {
					console.log(res);
					const { ResultCode, ResultData, ResultMessage } = res;
					if (ResultCode === 1) {
						this.state = ResultData;
						
						this.state.OtherAgreementInfo.AuditForList = ResultData.AuditForList;

						if (this.state.ShowLevel == 1) {
							this.DealerInfo.Dealer_BaseInfo = this.state.First_Dealer_BaseInfo;
						}
						if (this.state.ShowLevel == 2) {
							this.DealerInfo.Dealer_BaseInfo = this.state.Double_Dealer_BaseInfo;
						}
						
						this.DesignInfo.DesignPhotoList = this.state.DesignPhotoList;
						this.DesignInfo.DealerAuditInfo = this.state.DealerAuditInfo;
						this.DesignInfo.FileList = this.state.FileList;
						this.DesignInfo.InitialPhotoList = this.state.InitialPhotoList;
						this.loadCity = true;
					}
				});
		}
	}
};
</script>

<style></style>
